package com.crm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.crm.common.ResVo;
import com.crm.entity.GoodsChart;
import com.crm.service.GoodsChartService;
import com.spring4all.swagger.EnableSwagger2Doc;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@EnableSwagger2Doc
@RequestMapping("/goodsChart")
@Api(tags = "商品轮播图管理")
public class GoodsChartController {

	@Autowired
	private GoodsChartService goodsChartService;
	
	@PostMapping("/addGoodsChart")
	@ApiOperation("添加商品轮播图")
	public ResVo<Object> addGoodsChart(@RequestBody GoodsChart goodsChart) {
		goodsChartService.addGoodsChart(goodsChart);
		return ResVo.defaultSuccess();
	}
	
	@GetMapping("/getGoodsChartByGoodsId/{GoodsId}")
	@ApiOperation("根据商品id查询商品轮播图信息")
	public ResVo<Object> getGoodsChartByGoodsId(@PathVariable @ApiParam("商品Id") String GoodsId) {
		List<GoodsChart> message = goodsChartService.getGoodsChartByGoodsId(GoodsId);
		return ResVo.success(message);
	}
	
}
